import { axios } from '@/utils/request'
let uri = process.env.NODE_ENV === 'production' ? '' : '/yb'

const api = {
  updateSysDeptPosition: '/system/position/updateSysDeptPosition', //设置部门岗位的上级管理岗
  updateManagerPost: '/system/dept/updateManagerPost', // 设置是否管理岗
  insertDept: '/system/dept/insertDeptInfo',
  updateDept: '/system/dept/updateDeptInfo',
  updateOrder: '/system/dept/updateOrder',
  deleteDept: '/system/dept/deleteDeptInfo',
  deleteDeptUser: '/system/dept/deleteDeptUser', // 删除部门人员 
  queryDeptUserList: '/user/queryDeptUserList',
  getDeptById: '/system/dept/getDeptById',
  getDeptAllById: '/system/dept/getDeptAllById', // 通过id获取下级部门不分页
  // getPositionByDeptId: '/system/dept/getPositionByDeptId',
  getDeptTree: '/system/dept/getDeptTree',
  queryUserInfo: '/user/queryDeptUserList',
  updateUserInfo: '/user/updateDeptUserInfo',
  // 部门岗位管理
  getPositionByDeptId: '/system/position/getPositionByDeptId',
  // 部门岗位树
  getDeptPositionTree: '/system/dept/getDeptPositionTree',
  // 区域管理
  insertArea: '/area/create',
  updateArea: '/area/update',
  areaList: '/area/page',
  deleteArea: '/area/delete',
  getAreaTree: '/area/getAreaTree',
  updateOrder: '/area/updateOrder',
  queryPositionByDeptId: '/system/position/getPositionByDeptIdList',
  insertUserInfo: '/user/insertUserInfo',
  getDeptTreeByType: '/system/dept/getDeptTreeByType',
  getSysPositionRole: '/system/position/getSysPositionRole',
  updateSysPositionRole: '/system/position/updateSysPositionRole'
}
export function updateSysPositionRole(data) {
  return axios({
    url: api.updateSysPositionRole,
    method: 'put',
    data
  })
}

export function getSysPositionRole(params) {
  return axios({
    url: api.getSysPositionRole,
    method: 'get',
    params
  })
}

export function getDeptTreeByType(params) {
  return axios({
    url: api.getDeptTreeByType,
    method: 'get',
    params
  })
}

export function insertUserInfo(data) {
  return axios({
    url: api.insertUserInfo,
    method: 'post',
    data
  })
}


export function queryPositionByDeptId(params) {
  return axios({
    url: api.queryPositionByDeptId,
    method: 'get',
    params
  })
}

// getDeptPositionTree
export function getDeptPositionTree(params) {
  return axios({
    url: api.getDeptPositionTree,
    method: 'get',
    params
  })
}

// updateManagerPost
export function updateManagerPost(data) {
  return axios({
    url: api.updateManagerPost,
    method: 'put',
    data
  })
}

// deleteDeptUser
export function deleteDeptUser(id, params) {
  return axios({
    url: `${api.deleteDeptUser}/${id}`,
    method: 'delete',
    params
  })
}

// getDeptAllById
export function getDeptAllById(params) {
  return axios({
    url: api.getDeptAllById,
    method: 'get',
    params
  })
}

// updateSysDeptPosition
export function updateSysDeptPosition(data) {
  return axios({
    url: api.updateSysDeptPosition,
    method: 'put',
    data
  })
}

// 区域管理-新增
export function insertArea(data) {
  return axios({
    url: api.insertArea,
    method: 'post',
    data
  })
}

// 区域管理-修改
export function updateArea(data) {
  return axios({
    url: api.updateArea,
    method: 'put',
    data
  })
}
// areaList 区域管理-分页查询
export function areaList(params) {
  return axios({
    url: api.areaList,
    method: 'get',
    params
  })
}

// 区域管理-删除区域 deleteArea
export function deleteArea(id, params) {
  return axios({
    url: `${api.deleteArea}/${id}`,
    method: 'delete',
    params
  })
}

// 区域管理-获取区域树
export function getAreaTree(params) {
  return axios({
    url: api.getAreaTree,
    method: 'get',
    params
  })
}

// 部门管理
export function insertDept(paramter) {
  return axios({
    url: api.insertDept,
    method: 'post',
    data: paramter
  })
}

// 部门管理-修改部门
export function updateDept(paramter) {
  return axios({
    url: api.updateDept,
    method: 'put',
    data: paramter
  })
}

// 部门管理-修改排序
export function updateOrder(paramter) {
  return axios({
    url: api.updateOrder,
    method: 'put',
    params: paramter
  })
}

// 部门管理-删除部门
export function deleteDept(id, paramter) {
  return axios({
    url: `${api.deleteDept}/${id}`,
    method: 'delete',
    data: paramter
  })
}

// 部门管理-获取部门列表
export function getDeptById(paramter) {
  return axios({
    url: api.getDeptById,
    method: 'get',
    params: paramter
  })
}

// 部门管理-查询设置岗位列表  
export function getPositionByDeptId(parameter) {
  return axios({
    url: api.getPositionByDeptId,
    method: 'get',
    params: parameter
  })
}

// 部门管理-获取部门树 
export function getDeptTree(parameter) {
  return axios({
    url: api.getDeptTree,
    method: 'get',
    params: parameter
  })
}

// 部门人员管理-获取列表
export function queryDeptUserList(parameter) {
  return axios({
    url: api.queryDeptUserList,
    method: 'get',
    params: parameter
  })
}

// 部门人员管理-更新用户信息
export function updateUserInfo(parameter) {
  return axios({
    url: api.updateUserInfo,
    method: 'put',
    data: parameter
  })
}



